package com.qersoft.util;

public class ScoreUtils {

    public static int score(String userAnswer,String rightAnswer,int singleScoreFull,
                            int manyScoreFull,int manyScoreLack,int type)
    {
        String[] users = userAnswer.split(",");
        String[] rights = rightAnswer.split(",");
        if(users.length>rights.length)
            return 0;
        else{
            for(int i=0;i<users.length;i++){
                String s=users[i];
                int flag=1;
                for(int j=0;j<rights.length;j++){
                    if(s.equals(rights[j])){
                        flag=0;
                        break;
                    }
                }
                if(flag==1)
                {
                    return 0;
                }
            }
            if(users.length==rights.length)
            {
                if(type==1)
                {
                    return singleScoreFull;
                }
                else
                {
                    return manyScoreFull;
                }
            }
            else {
                if(type==1)
                {
                    return 0;
                }
                else
                {
                    return manyScoreLack;
                }
            }
        }

    }
}
